home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 13 April 1997
- // Author: ms
- //
- // Procedure Name:
- // cycleIntermediateObjectSibling
- //
- // Description:
- // For the shapes under a single transform where only one is
- // non-intermediate object and the other ones are - "cycle"
- // through them so that
- //
- // Input Arguments:
- // modifySelection - if set, the selection list is modified
- // to replace previously non-intermediate object
- // with a new non-intermediate object.
- //
- // Return Value:
- // None.
- //
-
-
- proc string getTheTransform( string $item )
- {
- string $result = $item;
- string $tmp[] = `ls -tr $result`;
- if( size($tmp) == 0 ) {
- $tmp = `listRelatives -p $result`;
- if( size($tmp) > 0 ) {
- $result = $tmp[0];
- }
- }
- return $result;
- }
-
- proc string needTheLeadTransform()
- {
- string $result = "";
- string $tmp[] = `ls -l -sl -tail 1 -type dagNode`;
- if( size($tmp) > 0 ) {
- $result = getTheTransform( $tmp[0] );
- }
- else {
- $tmp = `ls -l -sl -tail 1`;
- if( size($tmp) > 0 ) {
- $tmp = `listRelatives -p $tmp[0]`;
- if( size($tmp) > 0 ) {
- $result = getTheTransform( $tmp[0] );
- }
- }
- }
- return $result;
- }
-
- proc doModifySelection( string $oldVers, string $newVers )
- {
- string $act[] = `ls -sl`;
- int $i, $n;
- $n = size($act);
- for( $i=0; $i<$n; $i+=1 ) {
- $act[$i] = `substitute ($oldVers +"$") $act[$i] $newVers`;
- $act[$i] = `substitute ($oldVers +"\\.") $act[$i] ($newVers + ".")`;
- }
-
- select -cl;
- for( $i=0; $i<$n; $i+=1 ) {
- select -add $act[$i];
- }
- }
-
- global proc cycleIntermediateObjectSibling( int $modifySelection )
- {
- string $parent = `needTheLeadTransform`;
- if( $parent != "" ) {
- int $oldVisShape = -1;
- int $newVisShape = -1;
- int $i, $n, $val, $cntr;
- string $shapes[] = `listRelatives -s $parent`;
- string $tmp;
-
- // Now, we want only one
- $cntr = 0;
- $n = size($shapes);
- if( $n > 1 ) {
- for( $i=0; $i<$n; $i+=1 ) {
- $val = `getAttr ($shapes[$i] + ".io")`;
- if( ! $val ) {
- $oldVisShape = $i;
- $cntr += 1;
- }
- }
-
- if( 1 == $cntr ) {
- $newVisShape = $oldVisShape + 1;
- if( $newVisShape >= $n ) {
- $newVisShape = 0;
- }
-
- if( ($oldVisShape >= 0) && ($newVisShape >= 0) ) {
- setAttr ($shapes[$oldVisShape] + ".io") true;
- setAttr ($shapes[$newVisShape] + ".io") false;
-
- if( $modifySelection ) {
- doModifySelection( $shapes[$oldVisShape],
- $shapes[$newVisShape] );
- }
- }
- }
- }
- }
- }
-